// pages/local/local.js
var app = getApp()
var fileData = require('../../utils/data.js')
var req = require('../../utils/reqUtils.js');
Page({
  // 页面初始数据
  data: {
      // nav 初始化
      // cas picker
      colors : fileData.getColor(0),
      casIndex:0,
      // addr picker
      // nowLocation:util.getAddr(fileData.nowLocation()),
      addrIndex:0,
      // skillData: fileData.getSkilledData(),
      curNavId: 1,
      curIndex: 0,
  },
   
  onLoad:function() {
    var index = this.data.curIndex
    wx.setNavigationBarColor({
      frontColor: '#ffffff', // 必写项【该字体颜色仅支持 #ffffff 和 #000000 】
      backgroundColor: this.data.colors.topColor, // 传递的颜色值【仅支持有效值为十六进制颜色】
    })
    req.get('/carBands/getBands.do', {}, 1)
    .then(res => {
      this.setData({
        casArray:res.data
      })  
    })
    req.get('/saleServiceShop/getSaleServiceShopList.do', {}, 1)
    .then(res => {
      this.setData({
        carList:res.data
      })
      // console.log(this.data.carList)
    })
  },
  // 跳转至详情页
  navigateDetail: function(e){
    wx.navigateTo({
      url:'../local_detail/local_detail?shopId=' + e.currentTarget.dataset.aid
    })
  },
  // 加载更多
  loadMore: function (e) {
    console.log('加载更多')
    if (this.data.skillData.length === 0) return
    var that = this
    // 由于是模拟数据，加载更多时候，数据重复加载
    that.data.skillData= that.data.skillData.concat(that.data.skillData)
    that.setData({
      list: that.data.skillData,
    }) 
  },
  // 类别选择
  bindCasPickerChange:function(e) {
    let index =  e.detail.value
    console.log('Category picker发送选择改变，携带值为',index)
    this.setData({
      curIndex:index,
      casIndex:index
    })
  }
})